import { ref ,watchEffect} from 'vue'
import { getTopCategoryAPI } from '@/apis/category'
import { useRoute } from 'vue-router'

export function useCategory () {
const categoryData = ref({})
  const route = useRoute()
  const getCategory = async (id) => {
    const res = await getTopCategoryAPI(id)
    categoryData.value= res.data
  }
  watchEffect(() => { getCategory(route.params.id)})
  return { categoryData }
}